package com.stx.servlet.man;

import com.stx.bean.Car;
import com.stx.bean.Man;
import com.stx.mapper.CarMapper;
import com.stx.mapper.ManMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(urlPatterns = {"/manUpdate"})
public class ManUpdateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        String position = req.getParameter("position");
        String name = req.getParameter("name");
        String age = req.getParameter("age");
        String sex = req.getParameter("sex");
        String cardId = req.getParameter("cardId");
        Man man = new Man(id,position,name,age,sex,cardId);

        try {
            Boolean aBoolean = ManMapper.manUpdate(man);
            resp.sendRedirect("/manList");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

}
